package br.srv.full.virtual.engine.users;

import java.io.Serializable;
import java.util.List;

import br.srv.full.persistence.BeansManagerException;
import br.srv.full.virtual.bean.base.QueryID;
import br.srv.full.virtual.entities.auth.Login;
import br.srv.full.virtual.entities.auth.Person;
import br.srv.full.virtual.entities.auth.Role; 
import br.srv.full.virtual.entities.resume.UserLogin;

public interface PersonsManager extends Serializable {

	/**
	 * Confirma com o usuário seu registro.
	 * 
	 * Este metodo envia uma mensagem ao usuário e salva a tentativa de
	 * registro.
	 * 
	 * @param userLogin
	 */
	UserLogin confirmRegistration(UserLogin userLogin);

	/**
	 * Verifica a existencia do usuário no registro.
	 * 
	 * verifica com base no e-mail se o usuário já está cadastrado.
	 * 
	 * @param userLogin
	 * @return
	 */
	boolean consultIfEmailExist(UserLogin userLogin);

	/**
	 * Pesquisa no cadastro a existencia do usuario conforme a querie informada.
	 * 
	 * @param l_querieString
	 * @param firstFaseCode
	 * @return
	 */
	List<UserLogin> findUserLogin(QueryID l_querieString, String firstFaseCode);

	/**
	 * @param p_firstFaseCode
	 * @return
	 * @throws BeansManagerException 
	 */
	List<UserLogin> findUserLoginByUUID(String p_firstFaseCode) throws BeansManagerException;

	/**
	 * Atualiza detalhes do UserLogin
	 * 
	 * @param userLogin
	 */
	UserLogin update(UserLogin userLogin) throws PersonsManagerException;

	/**
	 * Troca a senha do usuário.
	 * 
	 * @param userLogin
	 * @param verifyPasswd
	 */
	UserLogin changePassword(UserLogin userLogin, String verifyPasswd) throws PersonsManagerException;

	/**
	 * Incrementa a contagem de acesso do UserLogin
	 * 
	 * @param userLogin
	 * @throws PersonsManagerException
	 */
	UserLogin increaseAccessCount(UserLogin userLogin) throws PersonsManagerException;

	/**
	 * @param p_userLogin
	 * @param p_msg 
	 * @throws PersonsManagerException
	 */
	void logSiteUse(UserLogin p_userLogin, String p_msg) throws PersonsManagerException;

	void logSiteUse(Login p_userLogin, String p_msg) throws PersonsManagerException;

	/**
	 * @param p_userLogin
	 * @return
	 */
	UserLogin createFirstLogin(UserLogin p_userLogin) throws FirstLoginException, PersonsManagerException;

	/**
	 * @param p_userLogin
	 */
	public UserLogin refreshUserLogin(UserLogin p_userLogin);

	/**
	 * atualiza um bean gravando no banco as diferenças.
	 * 
	 * @param p_user
	 * @return
	 * @throws PersonsManagerException
	 */
	<bean extends Person> bean update(bean p_user) throws PersonsManagerException;

	/**
	 * Atualiza um bean gravando no baco as diferenças com foco na propriedades
	 * que o compóe e que foram informadas.
	 * 
	 * @param <bean>
	 * @param p_bean
	 * @param p_properties
	 * @return
	 * @throws PersonsManagerException
	 */
	<bean extends Person> bean update(bean p_bean, String... p_properties) throws PersonsManagerException;

	/**
	 * atualiza o bean, com os dados existentes no banco.
	 * 
	 * @param p_bean
	 * @throws PersonsManagerException
	 */
	public <bean extends Person> bean refresh(bean p_bean, String... p_properties) throws PersonsManagerException;

	/**
	 * @param p_client
	 * @return
	 * @throws PersonsManagerException
	 */
	<bean extends Person> bean persist(bean p_client) throws PersonsManagerException;

	/**
	 * Persiste um bean, focando na propriedade que o compóe.
	 * 
	 * @param p_bean
	 * @param p_properties
	 * @return
	 * @throws PersonsManagerException
	 */
	<bean extends Person> bean persist(bean p_bean, String... p_properties) throws PersonsManagerException;

	/**
	 * @param p_client
	 * @return
	 * @throws PersonsManagerException 
	 */
	<bean extends Person> bean persistNew(bean p_client) throws PersonsManagerException;
 
	/**
	 * @param p_class
	 * @return
	 */
	<bean extends Person> Object find(Class<bean> p_beanClass);

	/**
	 * @return
	 */
	List<Role> getWorkerRoles();

}
